/*
 * To change this license header, choose License Headers in Project Properties. -->要更改许可证头，请在项目属性中选择许可证标头
 * To change this template file, choose Tools | Templates -- >要更改此模板文件，请选择工具模板
 * and open the template in the editor. --> 在编辑器中打开模板。
 */
package com.seari.bean.Line17;

/**
 *
 * @author Rainbow
 */
public class Line17Instruct
{
    public Line17Header header = new Line17Header();
    // 系统id
    public byte sysID;
    //盒子低位
    public byte packageNoLow;
    // 盒子高位
    public byte packageNoHigh;
    
    public byte totalLenLow;
    public byte totalLenHigh;
    public byte multiFlag;
    public byte msgID;
    public byte msgCountLow;
    public byte msgCountMid;
    public byte msgCountHigh;
    public byte startAddressLow;
    public byte startAddressMid;
    public byte startAddressHigh;
    public byte[] content;
    public byte chkLow;
    public byte chkHigh;
    
    public int getPackageNoInt()
    {
        return getHighLowByteValue(packageNoHigh, packageNoLow);
    }
    
    public int getTotalLenInt()
    {
        return getHighLowByteValue(totalLenHigh, totalLenLow);
    }
    
    public int getMsgCountInt()
    {
        return getTripleByteValue(msgCountHigh,msgCountMid,msgCountLow);
    }
    
    public int getStartAddressCountInt()
    {
        return getTripleByteValue(startAddressHigh,startAddressMid,startAddressLow);
    }
    
    private int getTripleByteValue(byte byteHigh , byte byteMid , byte byteLow)
    {
        int result;
        result = ((byteHigh & 0xff) << 16) | ((byteMid & 0xff) << 8) | (byteLow & 0xff);
        return result;
    }
    
    private int getHighLowByteValue(byte byteHigh ,byte byteLow)
    {
        int result;
        result = (((byteHigh & 0xff) << 8) | (byteLow & 0xff));
        return result;
    }
}
